package ipdesk.model.report.excel;



import ipdesk.common.Codes;

import java.util.List;
import java.util.Map;

import com.ibatis.dao.client.DaoManager;

import ecg.dao.DaoService;

public class ExcelDocumentDao
{
private static ExcelDocumentDao singleton;
	
	protected ExcelDocumentDao(){}
	
	public static ExcelDocumentDao getInstance()
	{
		if(singleton == null)
		{
			singleton = new ExcelDocumentDao();
		}
		
		return singleton;
	}
	
	private DaoManager	manager	= DaoService.getInstance();
	private IExcelDocument excelDocument 	= (IExcelDocument)manager.getDao(IExcelDocument.class, "ip_desk");
	
	/**
	 * 담당자 AND 센터에 해당하는 데이터를 가지고온다.
	 * 
	 * @param map
	 * @return
	 */
	public List<DocumentBean> getDataList(DocumentBean documentBean) throws Exception
	{
		List<DocumentBean> dataList = excelDocument.getDataList(documentBean);
		
		String reportGubun = documentBean.getReportGubun();
		
		if(reportGubun.equals("consult"))
		{
			if(dataList.size() > 1)
			{
				for(DocumentBean document : dataList)
				{
					document.setIprCode(Codes.getInstance().getFromIprCodeToValue(document.getIprCode()));
					document.setConsultingWayCode(Codes.getInstance().getFromConsultingWayCodeToValue(document.getConsultingWayCode()));
				}
			}
			
		}
		
		return dataList;
	}
}
